package com.example.parttimejob.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.parttimejob.mapper.ReviewsMapper;
import com.example.parttimejob.mapper.UserMapper;
import com.example.parttimejob.pojo.entity.Reviews;
import com.example.parttimejob.pojo.entity.User;
import com.example.parttimejob.pojo.entity.dto.ChangeReviewDto;
import com.example.parttimejob.pojo.entity.vo.ReviewUserVo;
import com.example.parttimejob.pojo.entity.vo.ReviewsVo;
import com.example.parttimejob.service.ReviewService;
import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/Review")
@CrossOrigin
public class ReviewController {

    @Autowired
    private ReviewService reviewService;

    //商家使用查看评论
    @GetMapping("/EvaluateStore/{Id}/{reviewerCategory}")
    public List<ReviewsVo> EvaluateStore(@PathVariable Integer Id, @PathVariable String reviewerCategory){
        return reviewService.EvaluateStore(Id,reviewerCategory);
    }

    //商家删除对用户的评论  或者用户删除对商家的评论
    @DeleteMapping("/DeleteStore/{reviewId}")
    public String DeleteStoreView(@PathVariable Integer reviewId)
    {
    return  reviewService.DeleteStoreView(reviewId);
    }

    //修改评论(评论表里)  商家用户均可以使用
   @PutMapping("/ChangeReview")
    public String ChangeReview(@RequestBody ChangeReviewDto changeReviewDto)
   {
       return reviewService.ChangeReview(changeReviewDto);
   }


   //
   //商家查看对某个兼职的评论
    @GetMapping("/StoreGetReviewByReview/{reviewerId}/{targetId}/{category}")
    public ChangeReviewDto StoreGetReviewByReview(@PathVariable Integer reviewerId,@PathVariable Integer targetId,@PathVariable String category)
    {
        return reviewService.StoreGetReviewByReview(reviewerId,targetId,category);
    }



    //用户使用查看评论
    @GetMapping("/EvaluateUser/{Id}/{reviewerCategory}")
    public List<ReviewUserVo> EvaluateUser(@PathVariable Integer Id, @PathVariable String reviewerCategory){
        return reviewService.EvaluateUser(Id,reviewerCategory);
    }






}
